/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2022并保留所有权利。
 * Copyright 2022, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.suanfa.test.test;

import java.util.*;
import sun.reflect.generics.tree.Tree;

public class Main {
    public static String leveltree(String str) {
        String[] tmp = str.split(" ");
        System.out.println(tmp);
         System.out.println(tmp[0]);
        List<Character> inOrder = new ArrayList<>();
         List<Character> posOrder = new ArrayList<>();
        for (char ch : tmp[0].toCharArray()) {
            if (Character.isLetter(ch)) {
                posOrder.add(ch);
            }
        }
        for (char ch : tmp[1].toCharArray()) {
            if (Character.isLetter(ch)) {
                inOrder.add(ch);
            }
        }
       MyBinarySTree<Character> mybst = MyBinarySTree.buildTree(inOrder,posOrder);

        return mybst.levelOrder().toString();
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String str = in.nextLine();
            String res = leveltree(str);
            System.out.println(res);
        }
    }

}


